﻿//
// Copyright (c) 2024 BPergaofeng
//
#ifndef BPerPUSH_BPerPUSHHANDLEIMPL_H_
#define BPerPUSH_BPerPUSHHANDLEIMPL_H_
#include <bperpush/BPerPushPublish.h>
#include <bperpush/BPerPushHandle.h>
#include <bperpush/BPerRtcPublish.h>
#include <bperpush/BPerSendVideoImpl.h>

#include <bperutil/sys/BPerUrl.h>


class BPerPushHandleImpl :public BPerPushHandle{
public:
	BPerPushHandleImpl(bool hasAudio,bool initVideo,int pvideotype,BPerVideoInfo* screenvideo,BPerVideoInfo* outvideo,BPerContext* pcontext,BPerSysMessageI* pmessage);
	virtual ~BPerPushHandleImpl();
	void init();
	void startCapture();
    int32_t publish(char* url,BPerBool isWihp);

	BPerVideoBuffer* getPreVideoBuffer();

	void disconnect();
	void changeSrc(int videoSrcType,bool pisinit);

	void addVr();
	void delVr();

	BPerSendVideoI* getSendVideo();
	BPerSendVideoImpl* m_send;

private:
    void startCamera();

    void stopCamera();

	void stopPublish();

	void switchToCamera(bool pisinit);

	void switchToOutside(bool pisinit);

private:
	bool m_hasAudio;
	int m_videoState;
	bool m_isInit;

	BPerPushPublish* m_cap;
	BPerRtcPublish* m_rtcPub;

	BPerContext* m_context;
	BPerUrlData m_url;
	BPerSysMessageI* m_message;
	BPerVideoInfo* m_screenInfo;

	BPerVideoInfo* m_outInfo;

};

#endif /* BPerPUSH_BPerPUSHHANDLEIMPL_H_ */
